﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SharpSoft.WPF.Controls
{
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Input;
    using System.Windows.Media;

    public class ImageRadioButton : RadioButton
    {
        static ImageRadioButton()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ImageRadioButton), new FrameworkPropertyMetadata(typeof(ImageRadioButton)));

        }
        public ImageRadioButton()
        {
            this.Content = null;
            this.TouchUp += ImageRadioButton_TouchUp;
        }

        private void ImageRadioButton_TouchUp(object sender, TouchEventArgs e)
        {
            this.IsChecked = true;
        }

        public Stretch ImageStretch
        {
            get { return (Stretch)GetValue(ImageStretchProperty); }
            set { SetValue(ImageStretchProperty, value); }
        }

        public static readonly DependencyProperty ImageStretchProperty =
            DependencyProperty.Register("ImageStretch", typeof(Stretch), typeof(ImageRadioButton), new PropertyMetadata(Stretch.Fill));



        /// <summary>
        /// 设置选中时的图形
        /// </summary>
        public ImageSource ImageChecked
        {
            get
            {
                var val = (ImageSource)GetValue(ImageCheckedProperty);
                return val;
            }
            set { SetValue(ImageCheckedProperty, value); }
        }

        public static readonly DependencyProperty ImageCheckedProperty =
            DependencyProperty.Register("ImageChecked", typeof(ImageSource), typeof(ImageRadioButton), new PropertyMetadata(null));



        /// <summary>
        /// 设置未选中时的图形
        /// </summary>
        public ImageSource ImageUnChecked
        {
            get
            {
                var val = (ImageSource)GetValue(ImageUnCheckedProperty);
                return val;
            }
            set { SetValue(ImageUnCheckedProperty, value); }
        }

        public static readonly DependencyProperty ImageUnCheckedProperty =
            DependencyProperty.Register("ImageUnChecked", typeof(ImageSource), typeof(ImageRadioButton), new PropertyMetadata(null));


    }
}
